package cn.edu.zzuli;

import cn.edu.zzuli.bean.User;
import cn.edu.zzuli.config.AppConfig;
import cn.edu.zzuli.mapper.UserMapper;
import cn.edu.zzuli.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;


public class Main {
    public static void main(String[] args) {

//        ApplicationContext context = new ClassPathXmlApplicationContext("application.xml");
//
//        UserMapper bean = context.getBean("userMapper",UserMapper.class);
//        for (User user : bean.getUsers()) {
//            System.out.println(user);
//        }

        ApplicationContext context =new AnnotationConfigApplicationContext(AppConfig.class);
        UserService service = context.getBean(UserService.class);
        User user = new User();
        user.setUsername("halo");
        user.setPassword("1132");

        service.addUser(user);
        service.getUsers().forEach(System.out::println);
    }
}
